<?php

class Admin extends Controller {

	function Admin()
	{
		parent::Controller();	
	}

  function index()
  {
    $user = $this->session->userdata('user');
    if ( ! isset($user['login']) )
    {
      redirect('/admin/login/');
    }
  }
	
	function login()
	{
    $post = $this->input->post();
    if (!isset($post['send_login']))
    {
      $this->load->view('login', array('login' => '', 'password' => ''));
      return;
    }

    $this->load->database();
    unset($post['send_login']);
    $this->db->where($post);
    $query = $this->db->get('user');
    if ($query->num_rows() != 1)
    {
      $this->load->view('login', $post);
      return;
    }
    $user = $query->row_array();
    $this->session->set_userdata('user', $user);
    redirect('/admin/');
  }

}

/* End of file admin.php */
/* Location: ./system/application/controllers/admin.php */